import numpy as np


def txt2intrinsic(intrinsic_path):
    I = []
    dist = None
    with open(intrinsic_path, "r") as f:
        for line in f:
            values = [float(v) for v in line.strip().split(",")]
            if len(values) == 3:
                I.append(values)
            else:
                dist = values
    I = np.float32(I)
    dist = np.float32(dist)
    return I, dist


def txt2timestamps(timestamps_path):
    ts = None
    with open(timestamps_path, "r") as f:
        for line in f:
            values = line.strip().split(",")
            ts = [int(v) for v in values]
            break
    return ts
